﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using FOModels.Customer;
namespace DataAccess.Customer
{
    public class CustomerDAL
    {
        private SQLDataAccess db;
        public CustomerDAL()
        {
            db = new SQLDataAccess();
        }
        public int InsertCustomer(CustomerModels cus)
        {
            return db.exeUpdate("insert into Customer values(N'" + cus.CustomerName + "',N'" + cus.Email + "',N'" + cus.Phone + "',N'" + cus.Address + "',N'" + cus.DOB + "',N'" + cus.InComing + "') ");
        }
        public DataTable Top1Customer()
        {
            return db.exeSelect("Select top 1 * from Customer order by CustomerID desc");
        }
        public DataTable SearchCustomerbyEmail(string email)
        {
            return db.exeSelect("Select * from Customer where Email ='" + email + "'");
        }
        public int UpdateCustomerInfo(CustomerModels cus)
        {
            return db.exeUpdate("update Customer set CustomerName = N'" + cus.CustomerName + "',Phone= N'" + cus.Phone + "',Address=N'" + cus.Address + "',DOB=N'" + cus.DOB + "',InComing=N'" + cus.InComing + "' where Email = '" + cus.Email + "'");
        }
    }
}
